<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 
<script type="text/javascript" src="../zbus.js"></script>
</head>
<body>      

<script type="text/javascript">   

const client = new MqClient("zbus.io");  

var mq = "MyMQ", channel = "MyChannel";   
 
function create(mq, channel){ 
    var msg = {};
    msg.headers = {
        cmd: 'create',
        mq: mq,
		mqType: Protocol.DISK,
		mqMask: Protocol.MASK_DELETE_ON_EXIT,
        channel: channel, 
    }; 

    client.invoke(msg).then(res=>{
        console.log(res);
    }); 
}
function sub(mq, channel){
    var msg = {};
    msg.headers = {
        cmd: 'sub',
        mq: mq,
        channel: channel, 
        window: 1,
    }; 
    client.invoke(msg).then(res=>{ 
        console.log(res); 
    }); 
}  
 
client.addMqHandler(mq, channel, msg=>{ 
    console.log(msg); 
});

client.onopen = ()=>{ 
    create(mq, channel);
    sub(mq, channel);
};

client.connect();

</script>
</body> 
</html>
